import axios from '../http';
import { Base, ResAId } from '../interface/base';

interface MaterialType extends Base {
	u_id: number;
	name: string;
	type: number;
}

const headers = { 'Content-Type': 'multipart/form-data' };

// 图片列表
export const getBgs: GetListApi<{}, MaterialType> = (params) => axios.get('mjconf/material', { params });

// 删除图片
export const delBg = (id: number) => axios.delete(`mjconf/material/${id}`);

// 上传图片
export const addBg = ({ data, type }: { data: FormData; type: number }): Promise<{ id: number; content: string }> =>
	axios.post('mjconf/material', data, { headers, params: { type } });
